package com.ha7419x.Controller;

import com.ha7419x.strategy.FactoryForStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
public class StrategyController {

    @Autowired
    FactoryForStrategy factoryForStrategy;

    @GetMapping("/strategy")
    public String strategy(@RequestParam("key") String key) {
        String result;
        try {
            result = factoryForStrategy.getStrategy(key).doSomething();
        } catch (Exception e) {
            result = e.getMessage();
        }
        return result;
    }
}
